**********************************************************************************************
* Reproduces Table A1
*
* Ajzenman, Elacqua, Jaimovich and Pérez-Núñez (2024)."Humans versus Chatbots: Scaling-up behavioral interventions to reduce teacher shortages"  	  		
*
**********************************************************************************************

matrix drop _all
mat D=J(16,7,.)
local i= 2
 
*Sample stratification in covariates 

foreach var in male female  municipal subvencionado particular top_30 {

sum `var' if `var'==1
mat D[1,`i']= r(N)

sum `var' if `var'!=.
mat D[2,`i']= r(mean)*100

sum `var' if `var'==1 & education_preference==1
mat D[3,`i']= r(N)

sum `var' if  education_preference==1 & `var'!=.
mat D[4,`i']= r(mean)*100

sum `var' if `var'==1 & grupo_det=="Humano"
mat D[5,`i']= r(N)

sum `var' if  grupo_det=="Humano"  & `var'!=.
mat D[6,`i']= r(mean)*100

sum `var' if `var'==1 & grupo_det=="Bot A"
mat D[7,`i']= r(N)

sum `var' if  grupo_det=="Bot A"  & `var'!=.
mat D[8,`i']= r(mean)*100

sum `var' if `var'==1 & grupo_det=="Control A"
mat D[9,`i']= r(N)

sum `var' if  grupo_det=="Control A"  & `var'!=.
mat D[10,`i']= r(mean)*100

sum `var' if `var'==1 & education_preference==0
mat D[11,`i']= r(N)

sum `var' if  education_preference==0  & `var'!=.
mat D[12,`i']= r(mean)*100

sum `var' if `var'==1 & grupo_det=="Bot B"
mat D[13,`i']= r(N)

sum `var' if  grupo_det=="Bot B"  & `var'!=.
mat D[14,`i']= r(mean)*100

sum `var' if `var'==1 & grupo_det=="Control B"
mat D[15,`i']= r(N)

sum `var' if  grupo_det=="Control B"  & `var'!=.
mat D[16,`i']= r(mean)*100


local i =`i'+1
}

sum mrun if no_covariates==0
mat D[1,1]= r(N)

sum mrun if no_covariates==0 & education_preference==1
mat D[3,1]= r(N)

sum mrun if no_covariates==0 & grupo_det=="Humano" 
mat D[5,1]= r(N)

sum mrun if no_covariates==0 & grupo_det=="Bot A"
mat D[7,1]= r(N)

sum mrun if no_covariates==0 & grupo_det=="Control A"
mat D[9,1]= r(N)

sum mrun if no_covariates==0 & education_preference==0
mat D[11,1]= r(N)

sum mrun if no_covariates==0 & grupo_det=="Bot B"
mat D[13,1]= r(N)

sum mrun if no_covariates==0 & grupo_det=="Control B"
mat D[15,1]= r(N)

matlist D

mat rownames D= "Full Sample" "."  "Interested in education" "." "Human" "."  "Bot" "." "Control" "-. ""Interested in social sciences"  "." "Bot" "." "Control" "."
mat colname D= "Size" "Male" "Female" "Public" "Priv. Sub." "Private" "Top 30%"

matlist D

frmttable using "${output}/TableA1.tex", statmat(D) varlabels replace sdec(0,3,3,0,0,0) tex fr
